home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
fractals
/
polysys
/
polysys.docs
< prev
next >
Wrap
Text File
|
1994-11-17
|
24KB
|
462 lines
/* PolySys 1.0 ©1990 by Terry W. Gintz */
PolySys is an extended version of the 0L-system (string rewriting) described
in The Science of Fractal Images (edited by Pietgen and Saupe.) The basic
algorithm has been expanded and modified extensively, and looping commands
similiar to those found in other Turtle graphics systems (Logo, etc) have
been added. Support for three-dimensional drawing, with perspective, is also
included in PolySys. To enable the program to run on an Amiga 500 without
extra memory, an alterate method of string interpretation has been
implemented, using recursion. String size is kept to a minimum, while the
axiom is interpreted character by character.
For those who are not familiar with L-systems, a discussion of their basic
features and how they differ from other turtle graphics is a good starting
point. Lsystems have as their base an axiom, which is a string of character
commands, or a single character. The character can be a command in itself,
such as 'F' for forward, or it may be a production rule, which is a string of
commands also. The axiom and production rules are created and edited with
separate editors. When the axiom is 'run', the axiom is scanned for
commands and/or rules. Recursion is used to substitute where necessary a
production rule string for a single character, to the depth specified at
runtime. In 0L-systems, quite long character strings can be built this way
and then executed. Once the string is built, it is then stripped of
non-commands and executed without displaying the commands on the screen.
The size of the drawing object is thus established and it is then scaled and
drawn on the screen. The first significant difference from other turtle
graphics systems is now apparent: self-scaling. The object will never
overrun the screen boundaries. Objects can be displayed to the limits of
the window, regardless of window size. PolySys uses a 640X400 hi-res
screen, but any resolution is possible.
L-systems have a stack available to keep track of turtle position and
variables whenever it is necessary to return to a particular point in the
drawing. This is useful for producing tree structures and other branching
patterns. PolySys puts on its stack the turtle postion, headings,
linestyle, and color information.
The third significant difference between L-systems and other turtle graphics
interpreters is in its handling of recursion. In L-systems, recursion is a
built-in feature. You only need to specify the level of recursion, and the
system does its string interpretation to that level. PolySys uses recursion
to call its own interpretation routines, and thus eliminates the need for
lengthy strings to interpret.
The price for the above built-in features is speed. Lsystems can never be
as fast drawing a dragon curve, for instance, as a dedicated dragon-drawing
program. On the other hand, fractal generators have trouble matching the
speed of L-systems where branching patterns are involved. There is no need
to recurse backwards to reach a branching node in L-systems: just pop the
stack, and you're there. PolySys is capable of rendering polygons in three
dimensions, but cannot match the speed of a dedicated 3-D modeler such as
PageRender3D. There is no hidden-line removal or shading included in
PolySys, except for solid area fills or flood fill. The 3-dimensional
features can be used to produce more realistic looking plants than
a 2-dimensional L-system could produce. L-systems such as PolySys offer the
user a chance to experiment with a very different approach to graphics
production. The author has included many examples of possible
approaches to using PolySys, but these are only initial exercises, like
tuning a guitar. Productions of imaginative insight remain to be created
and explored.
The following is a decription of the features of PolySys, starting with
menus and windows, and concluding with available commands.
The Menus:
The Main or Project menu:
'New' -- Erases the current axiom and production rules from memory. Will
ask for confirmation before doing so.
'Clear' -- Clears the drawing window to the color specified by the
background menu, one of 16 colors.
'Draw' -- Opens the runtime window, which includes gadgets to set rotation
angles, perspective, scale of drawing, and depth of drawing, etc. This
window has options to draw or redraw the current axiom, or draw a
perspective version of the axiom (if in 3-D mode). You can abort the drawing
at any time by clicking in the drawing window with the left mouse button.
'Save' -- Saves the current axiom and production rules, background, rotation
angles and depth. Scale and perspective are not saved. A custom icon is
created for each data file, that can load PolySys and draw itself from the
Workbench. You can save an axiom without production rules, or rules without
an axiom, but you can't load and draw the latter.
'Load' -- Loads an axiom and its associated data, and runs the axiom, if not
NULL. Does not automatically clear the screen each time an axiom is loaded,
so you can display multiple axioms on the drawing window.
'Save' and 'Load' use a Charlie Heath file requester to save and retrieve
data files. Enter the directory name into the upper box of the requester,
or leave blank for the current directory. Click on the file you wish to
load, or enter a name in the file name box. Click on Okay to load the file
or click Cancel to abort the operation.
'Quit' exits the program.
The Edit menu:
'Axiom' -- opens the axiom editor window.
'Rules' -- opens the rules editor window.
The Background menu:
You set the background color to any of 16 colors specified by the elements
of this menu. Does not automatically clear the screen. You have to use the
choose 'Clear' on the main menu to clear the screen to the color selected.
Alternately, see use of the axiom/rule command 'c'.
The Windows:
The main drawing window is a hi-res interlaced window 640X400. Smart
refresh is used to save the current image while other windows are in use.
The runtime draw window has gadgets to set projection angles in 3-D mode.
These are not used in 2-D mode. You enter the level of recursion into the
level gadget. The maximum level of recursion is limited to 50.
Use the scale slider to set the size of the drawing, .01 to full-size.
Use the perspective slider to set the amount of perspective
desired, if in 3-D mode. A range of 1-30 is allowed, with 1 being the
maximum perspective. The perspective option is available only after the
figure has been drawn without perspective. (The parser needs to know limits
on the figure size to calculate perspective.) You don't have to wait for the
first drawing to finish to use perspective. Click on Draw to recompute
and draw the current axiom. Click on Redraw to redraw the figure after it
has been drawn once. Use this option after changing background, or clearing
the screen. Click on Perspect, if enabled, to draw a perspective version of
the current axiom.
The axiom editor:
Enter the maximum number of angles in the number box, 1-360. Enter an
axiom, up to 55 characters in the axiom box. Click on Okay to set the new
axiom into memory. Click on Cancel to revert to the previous axiom. You
must have a number in the number box >0, for the Okay option to work.
Entering an axiom enables the Save and Draw options on the Main menu. See a
description of the available commands, if unsure what is acceptable as an
axiom.
The rules editor:
The top row of gadgets are the command line gadgets, and the string gadgets
are used to enter production rules and labels.
The string gadgets:
'Rule' -- enter up to 45 characters for each production rule.
'ARule' -- enter up to 45 characters for an alternate production rule, if
a number greater than 0 is entered into the Prior gadget. Otherwise, the
ARule is added to the Rule for a double-long production rule.
'Prior' -- sets a priority from 0-9 for the ARule. A random generator is
then used to decide which rule to use at runtime. If the random number is
less than the Priority then the ARule is used (even if NULL.) If Prior is
set to zero, the main Rule is